package com.nbsaas.boot.app.rest.resource;

import com.nbsaas.boot.app.api.apis.AppApi;
import com.nbsaas.boot.app.api.domain.request.AppRequest;
import com.nbsaas.boot.app.api.domain.response.AppResponse;
import com.nbsaas.boot.app.api.domain.simple.AppSimple;
import com.nbsaas.boot.app.data.entity.App;
import com.nbsaas.boot.app.data.repository.AppRepository;
import com.nbsaas.boot.app.rest.convert.AppEntityConvert;
import com.nbsaas.boot.app.rest.convert.AppResponseConvert;
import com.nbsaas.boot.app.rest.convert.AppSimpleConvert;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.function.Function;

/**
 *   -业务接口实现
 */
@Transactional
@Service
public class AppResource extends BaseResource<App, AppResponse, AppSimple, AppRequest> implements AppApi {

    @Resource
    private AppRepository appRepository;

    @Override
    public JpaRepositoryImplementation<App, Serializable> getJpaRepository() {
        return appRepository;
    }

    @Override
    public Function<App, AppSimple> getConvertSimple() {
        return new AppSimpleConvert();
    }

    @Override
    public Function<AppRequest, App> getConvertForm() {
        return new AppEntityConvert();
    }

    @Override
    public Function<App, AppResponse> getConvertResponse() {
        return new AppResponseConvert();
    }


}


